// pages/userCenter/index.js
const app = getApp();

Page({
  /**
   * 页面的初始数据
   */
  data: {
    image: "https://img1.baidu.com/it/u=1167785969,3358198230&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800",
    userInfo: {},
    showUserInfo: false, //弹出个人信息
    showQR: false, //弹出售后二维码

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      userInfo: app.globalData.userInfo,
      hasUserInfo: true,
    });
  },

  //弹出个人信息
  showPopup: function () {
    this.setData({
      showUserInfo: true,
    });
  },
  showQR() {
    this.setData({
      showQR: true,
    });
  },
  //关闭弹出层
  onClose() {
    this.setData({
      showUserInfo: false,
      showQR: false
    });
  },
  // 退出登录
  onExitHandle: function () {
    app.loginOut();
    wx.reLaunch({
      url: "/pages/login/index",
    });
    wx.showToast({
      title: "已登出",
    });
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    if (typeof this.getTabBar === "function" && this.getTabBar()) {
      const route = "/" + this.route;
      const tabList = this.getTabBar().data.list;
      const current = tabList.find((i) => i.pagePath === route);
      if (current) {
        this.getTabBar().setData({
          value: current.value
        });
      }
    }
  },


});